/**
 * 页面按钮权限显示
 */
import { getPageBtnView } from '@/api/scene.js'

export default {
  state: {
    currentBtnList: []
  },
  mutations: {
    'GET_CURRENT_BTN_LIST' (state, payload) {
      state.currentBtnList = payload
    }
  },
  actions: {
    async getBtnPermission ({ commit }, payload) {
      let userInfo = localStorage.getItem('Standard__User-Info')
      const tenantNo = JSON.parse(userInfo).value.tenantNo
      const { meta } = payload
      try {
        const res = await getPageBtnView({
          menuNo: meta.pkId,
          sceneNo: meta.sceneNo,
          tenantNo,
          roleNo: '',
          pageNum: 1,
          pageSize: 10000
        })
        if (res.code === 0) {
          commit('GET_CURRENT_BTN_LIST', res.data.list)
        }
      } catch (e) {}
    }
  }
}
